package Domain;

import Domain.DataStructures.IRecommendationData;

import java.io.Serializable;
import java.util.Date;
import java.text.ParseException;
import java.text.DateFormat;


/**
 * This class contains all the information about a recommendation of a user to movie in the system
 */
public class Recommendation implements IRecommendationData, Serializable {
    // contains the recommendation of user on specific movie
    private String m_userName;
    private String m_movieName;
    private String m_description;
    private int m_userRank;
    private String m_date;


    public Recommendation(String m_userName, String m_movieName, String m_description, int m_userRank) {
        this.m_userName = m_userName.trim();
        this.m_movieName = m_movieName.toLowerCase().trim();
        this.m_description = m_description.trim();
        this.m_userRank = m_userRank;
        this.m_date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date());
    }

    public Recommendation(String m_userName, String m_movieName, String m_description, int m_userRank, String date){
        this.m_userName = m_userName.trim();
        this.m_movieName = m_movieName.toLowerCase().trim();
        this.m_description = m_description.trim();
        this.m_userRank = m_userRank;
        this.m_date = date;
    }

    public String getUserName() {
        return m_userName;
    }

    public String getMovieName() {
        return m_movieName;
    }

    public String getDescription() {
        return m_description;
    }

    public int getUserRank() {
        return m_userRank;
    }

    public Date getRecommendationDate() {
        Date result = null;
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
        try {
            result = dateFormat.parse(this.m_date);
        }
        catch (ParseException e) {
            System.out.println("can't convert string "+ this.m_date+ " to Date");
            e.printStackTrace();
        }
        return result;
    }

    public String getDate(){
        return this.m_date;
    }
}
